using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using PGLNet;

namespace PGLNetTest
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	class Class1
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			try
			{

				PglLoader eload=new PglLoader(true,true);

				int n=100;
				double[] x=new double[n];
				double[] y=new double[n];

				IntPtr px=IntPtr.Zero;
				IntPtr py=IntPtr.Zero;
				
				for (int i=0;i<n;++i)
				{
					x[i]=((float)i)/n;
					y[i]=x[i]*x[i];
				}

				PglRegion.AutoZoom = false;
				PglRegion r = PglRegion.Create();
				r.Plot(PglData.Adapt(x),PglData.Adapt(y),"");
				// dividing
				r.Divide(2,1);
				r.ZoomAll(false);

				PglRegion c = r.ChildItem(0);
				c.Plot( PglData.Adapt(x),PglData.Adapt(y),null);
				c.LeftLabel = "my left";
				c.RightLabel = "my right";
				c.BottomLabel = "my bottom";
				c.Title = "my title";
				c.SetBackgroundGradient(Color.Gray, Color.White, 45);
				RectangleF re = new RectangleF(0.1f,0.1f,0.8f,0.2f) ;
				c.Zoom = re;

				c=r.ChildItem(1);
				c.Plot(PglData.Adapt(x), PglData.Adapt(y),null);
				PglLine l = c.PlotLOD(PglData.Adapt(x), PglData.Adapt(y),0.1f,"rs");
				l.Interpolation = PglLine.InterpolationType.InterpolationStep;
				l.Tension = 0.5f;
				c.SetBackgroundColor(Color.Aqua);
				c.ZoomAll(false);
				Serializer.RenderToFile(r, "test.png", "type=png dim=400x400");
			}
			catch(Exception e)
			{
				Console.WriteLine( e.Message );
			}
		}
	}
}
